package com.jimmy.ioc.team;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @version 1.0
 * @ ClassName App
 * <p> TODO
 * @ author JIMMY
 * @ Date 2020/10/22 0022 下午 9:41
 */
public class App {
    public static void main(String[] args) {
//        test1();
//        test2();
//        test3();
        test4();
    }
    public static void  test1(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-user.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();
    }
    public static void test2(){
        //一次性加载多个XML文件
//        格式一
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-user.xml","applicationContext.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();
    }
    public static void test3(){
        //一次性加载多个XML文件
//        格式二
        String[] confs = new String[]{"applicationContext.xml","applicationContext-user.xml"};
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(confs);
        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();
    }

    public static void  test4(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-user.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        userService.save();
    }
}
